package webx

import (
	"context"
	"net/http"
)

type contextImpl struct {
	context.Context
	path               string
	traceId            string
	request            any
	responst           any
	httpRequest        *http.Request
	httpResponseWriter http.ResponseWriter
}

func NewContext(path string) context.Context {
	return newContext(path)
}

func newContext(path string) *contextImpl {
	ctx := &contextImpl{path: path, Context: context.Background()}
	ctx.traceId = CreateSequence()
	return ctx
}

func (ctx contextImpl) GetPath() string {
	return ctx.path
}

func (ctx *contextImpl) GetTraceId() string {
	return ctx.traceId
}

func (ctx *contextImpl) GetRequest() any {
	return ctx.request
}

func (ctx *contextImpl) GetResponse() any {
	return ctx.responst
}

func (ctx *contextImpl) GetHttpRequest() *http.Request {
	return ctx.httpRequest
}

func (ctx *contextImpl) GetHttpResponseWriter() http.ResponseWriter {
	return ctx.httpResponseWriter
}
